package com.hp.idempotence.v3.config;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:/datasource.properties")
public class DataSourceConf {
	
	//配置方式一
	@Bean
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource dataSource(){
        DataSource dataSource= DataSourceBuilder.create().build();
        return dataSource;
    }
	
	//配置方式二
	/*@Bean
	@ConfigurationProperties(prefix = "spring.datasource")
	public DataSource getDataSource(){
		DataSource dataSouece = new HikariDataSource();
		return dataSouece;
	}*/
	
	

}
